Skip to content

Protect only the tests of the rules for compiled code, not all of _compilation_test.py - #911

Merged
perlinm merged 1 commit into
mainfrom
refactor/compiled-code-rule-tests
Nov 16, 2026
Merged

perlinm merged 1 commit into
mainfrom
refactor/compiled-code-rule-tests

Conversation

@perlinm

@perlinm perlinm commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Motivation

AGENTS.md protects the tests that enforce the standards, and those protected files change only through a patch that a maintainer approves. It listed all of _compilation_test.py, because code.rst says that file enforces the rules for Numba code. But only five of its 33 tests enforce rules: they read the source and check how compiled functions are declared, called, imported, and placed. The rest test what _compilation.py does (the disk cache, the source hash, the registry of compiled-on-request functions, and the switch to plain Python) and the pytest options of the compiled runs. So routine compilation work needed an approved patch to change its tests; seven pull requests (#821 to #908) changed this file in the nine days after #768 protected it.

Changes

The five rule tests, the test of their helper, and their helpers move unchanged, except for docstrings, to a new file, src/qldpc/_compiled_code_rules_test.py. It replaces _compilation_test.py in the list of protected files in AGENTS.md, and code.rst and the distance README now cite it. _compilation_test.py keeps the tests of behavior, including the test that the compiled runs select the right test files, which mainly tests conftest.py. The new file's docstring notes that this unprotected test also catches a module whose only compiled functions use neither decorator. Each file now builds its own program that imports every module of qLDPC, so neither test file imports the other.

The rules for working on qLDPC keep the same length, since one file name replaces another, and no rule is replaced; only which tests are protected changes.

Validation

Two independent reviewers compared four options: keep all of _compilation_test.py protected, move the rule tests into _code_style_test.py, move them into a new protected file, or stop protecting them. Both chose a new file, since _code_style_test.py covers module layout. The moved tests are line-for-line copies apart from docstrings, and the compiled runs select the same test files as before.

…mpilation_test.py

Move the five tests that enforce the code standard's rules for compiled
functions, the test of their helper, and their helpers to a new file,
_compiled_code_rules_test.py, which replaces _compilation_test.py in the
list of protected files in AGENTS.md.  code.rst and the distance README
cite the new file.  _compilation_test.py keeps the tests of what
_compilation.py and the compiled-run options do.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@perlinm
perlinm merged commit b43f414 into main Nov 16, 2026
9 checks passed
@perlinm
perlinm deleted the refactor/compiled-code-rule-tests branch November 16, 2026 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant